# coding:utf8
"""
author:shadu@foxmail.com
"""
import redis
from dbconfig import *

class RedisDB(object):
    """
    代理服务器 Redis 数据库单实例类
    """

    __instance = None

    def __init__(self):
        pool_collected = redis.ConnectionPool(host=redis_proxy_collected['host'],
                                              password=redis_proxy_collected['password'],
                                              port=redis_proxy_collected['port'],
                                              db=redis_proxy_collected['db'])

        pool_to_verify = redis.ConnectionPool(host=redis_proxy_to_veify['host'],
                                              password=redis_proxy_to_veify['password'],
                                              port=redis_proxy_to_veify['port'],
                                              db=redis_proxy_to_veify['db'])

        pool_history = redis.ConnectionPool(host=redis_proxy_history['host'],
                                            password=redis_proxy_history['password'],
                                            port=redis_proxy_history['port'],
                                            db=redis_proxy_history['db'])

        self.redis_conn_collected = redis.StrictRedis(connection_pool=pool_collected)
        self.redis_conn_to_veify = redis.StrictRedis(connection_pool=pool_to_verify)
        self.redis_conn_history = redis.StrictRedis(connection_pool=pool_history)

    def __new__(cls):
        if cls.__instance is None:
            cls.__instance = object.__new__(cls)
        return RedisDB.__instance


if __name__ == '__main__':
    print RedisDB()